package asava.sources;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.CharBuffer;

/**
 * @author Tim Richter
 */
public final class Source {
    public final File file;

    public Source(final File file) {
        this.file = file;
    }

    public char[] content() throws IOException {
        try (final BufferedReader br = new BufferedReader(new FileReader(file), 1024)) {
            final CharBuffer buf = CharBuffer.allocate((int) file.length());
            br.read(buf);
            br.close();
            return buf.array();
        }
    }
}
